home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
5_6.lha
/
5_6
/
5_6b.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
786b
|
45 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ implement a character queue using
/ an array
include <char_queue.h>
include <error.h>
har_queue:: char_queue(int nummembers)
base = new char[nummembers];
end = &base[nummembers];
front = rear = base;
har_queue:: ~char_queue()
delete base;
oid char_queue:: enqueue(char c)
*rear++ = c;
if (rear == end)
rear = base;
if (rear == front)
error("overflow of character queue");
har char_queue:: dequeue()
if (emptyQ())
error("underflow of character queue");
char ch = *front++;
if (front == end)
front = base;
return ch;
oid char_queue:: clearQ()
front = rear = base;